<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="com.wanmait.hotelManage.vo.Order"%>
<%@page import="com.wanmait.hotelManage.vo.RoomType"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path=request.getContextPath();
	List<Order> list=(List<Order>)request.getAttribute("list");
	List<Double> prices=(List<Double>)request.getAttribute("prices");
%>
  <table class="result-tab" width="100%">
                        <tr>
                            <th>ID</th>
                            <th>用户</th>
                            <th>入住人</th>
                            <th>电话号码</th>
                            <th>录入时间</th>
                            <th>入住时间</th>
                            <th>结束时间</th>
                            <th>是否有早餐</th>
                            <th>是否预定车</th>
                            <th>发车时间</th>
                            <th>结束时间</th>
                            <th>支付金额</th>
                        </tr> 
                       <%
                        	for(int i=0;i<list.size();i++)
                        	{
                        %>                                             	
                        	<tr id="content">
                               <td height="50px"><%=list.get(i).getId() %></td>
                               <td><%=list.get(i).getUserinfo().getUsername() %></td>
                               <td><%=list.get(i).getName() %></td>
                               <td><%=list.get(i).getTelephoneNumber() %></td>
                               <td><%=list.get(i).getInputTime() %></td>
                               <td><%=list.get(i).getStartTime().toString().substring(0,10) %></td>
                               <td><%=list.get(i).getEndTime().toString().substring(0,10) %> </td> 
                               <td id="breakfast"><%=list.get(i).getBreakfast()==true?"有早餐":"无早餐" %></td>
                               <td id="car"><%=list.get(i).getCar()==true?"有车":"无车" %></td>
                               <td><%=list.get(i).getCarStartTime()==null?"无":list.get(i).getCarStartTime() %></td>
                               <td><%=list.get(i).getCarEndTime()==null?"无":list.get(i).getCarEndTime() %></td>
                                <td id="enable"><%=prices.get(i) %></td> 
                            </tr>
                        <%
                        	}
                        %>                          
                    </table>
                    
                    <!-- 显示数字 -->
	<%Pager pager = (Pager)request.getAttribute("pager"); %>
	<div style="text-align: center;">
<%
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		if(pager.getPageNo()!=i){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}else{
                    		%>
                    		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                    }
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
</div>
	<!-- 显示数字的结束 -->
                    
  <script>
	$(function(){
		
		$(".no").click(function(){
			/* $(".number").css("color","black");
			$(this).css("color","red"); */
			var cont=<%=pager.getPageNo()%>;
			if(cont<<%=pager.getPageCount()%>){
			cont++;
			}
			$.ajax({
				url:"<%=path%>/manage/OrderServlet?action=getOrder",
					data:{pageNo:cont},
						success:function(msg){
							$(".result-content").html(msg);
						}
			})
		})
		$(".ok").click(function(){
				/* $(".number").css("color","black");
				$(this).css("color","red"); */
				var cont=<%=pager.getPageNo()%>;
				if(cont>1){
				cont--;
				}
				$.ajax({
					url:"<%=path%>/manage/OrderServlet?action=getOrder",
					data:{pageNo:cont},
						success:function(msg){
							$(".result-content").html(msg);
						}
					})
			})		
			
			$(this).css("color","red");
			var n=$(this).html();//获得当前点击的数字
			$.ajax({
				url:"<%=request.getContextPath()%>/manage/OrderServlet",
				type:"get",
				data:{action:"getOrder",pageNo:n},
				success:function(mes){
					$(".result-content").html(mes);
				}
			});
		});

</script>                  
<script>                  
			$(".aaa").css("color","red");
</script>                  
                    
              
   
